package com.wuwei.aliocr.controller;

import com.wuwei.aliocr.domain.Model;
import com.wuwei.aliocr.domain.Teacher;
import com.wuwei.aliocr.result.Result;
import com.wuwei.aliocr.service.AuthorizationService;
import com.wuwei.aliocr.service.LessonRecordService;
import com.wuwei.aliocr.service.ModelService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value="/model")
@CrossOrigin
public class ModelController {

    @Resource
    private ModelService modelService;

    @Resource
    private AuthorizationService authorizationService;

    @Resource
    private LessonRecordService lessonRecordService;

    @GetMapping("/getModelList")
    public Result<List<Model>> getModelList(){
     List<Model> list =  modelService.getModelList();
     return Result.ok(list);
    }

    /**
     * 根据传入的模块名称查询到获得该模块授权的教员
     * @param model
     * @return
     */
    @GetMapping("/getAuthorizedTeacher/{model}")
    public Result<List<Teacher>> getAuthorizedTeacher(@PathVariable("model") String model){
        List<Teacher> list =  authorizationService.getAuthorizedTeacher(model);
        return Result.ok(list);
    }

    /**
     * 获得班级编号，班级编号是sql中lessonsrecord的remark字段
     * @return
     */
    @GetMapping("/getLessonRecord/getRemark")
    public Result<List<String>> getClassNum(){
        List<String> list =  lessonRecordService.getClassNum();
        return Result.ok(list);
    }

}
